/*
 * Copyright 2006-2015 Transsion.com All right reserved. This software is the confidential and proprietary information
 * of Transsion.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it
 * only in accordance with the terms of the license agreement you entered into with Transsion.com.
 */
package com.yunji.framework_template.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * ClassName:ExceptionControler <br/>
 * Date: 2016年1月22日 上午11:12:46 <br/>
 * 
 * @author fenglibin
 * @version
 * @see
 */
@Controller
public class ExceptionControler {
    @Value("#{settings['system.domain']}")
    private String      systemDomain;
    
    @RequestMapping(value = "/404", method = RequestMethod.GET)
    public ModelAndView notFound(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("404");
        view.getModelMap().addAttribute("systemDomain", systemDomain);
        return view;
    }

    @RequestMapping(value = "/500", method = RequestMethod.GET)
    public ModelAndView serverError500(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("500");
        view.getModelMap().addAttribute("systemDomain", systemDomain);
        return view;
    }

    @RequestMapping(value = "/error", method = RequestMethod.GET)
    public ModelAndView serverCommonError(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("error");
        view.getModelMap().addAttribute("systemDomain", systemDomain);
        return view;
    }
}
